from datetime import date
from fastapi import FastAPI, APIRouter, Query, HTTPException, Path
from src.models import check_models
from src.db import db_models
from src.sevices import JOB_SERVICES

job_router = APIRouter()


# 学生就业管理模块
# 按照学生编号查询就业信息
@job_router.get('/{sid}', summary="按照学生编号查询就业信息")
async def get_job_info(sid: int):
    return await JOB_SERVICES.get_job_by_info(sid)


# 按照公司名字查询就业信息
@job_router.get('/company/', summary='按照公司名字查询就业信息')
async def get_job_info(com_name: str):
    return await JOB_SERVICES.get_job_by_name(com_name)


# 按照工资范围查询就业信息
@job_router.get('/sal_range/', summary='按照工资范围查询就业信息')
async def get_sal_range(min_sal: int = Query(..., gt=0, description="最低工资"),
                        max_sal: int = Query(..., gt=0, description="最高工资")):
    return await JOB_SERVICES.get_sal_range(min_sal, max_sal)


# 定义基类


# 修改就业信息——增加新的
@job_router.post('/', summary='新增就业信息')
async def add_job(job: check_models.JobModel):
    return await JOB_SERVICES.add_job(job)


# 修改就业信息——修改原有的
@job_router.put('/{sid}', summary='修改就业信息')
async def update_job(job_id: int, job: check_models.JobModel):
    return await JOB_SERVICES.update_job(job_id, job)


# 删除就业信息
@job_router.delete('/{sid}', summary='删除就业信息')
async def delete_job_info(sid: int):
    return await JOB_SERVICES.delete_job_info(sid)
